/*
 * @Author: your name
 * @Date: 2021-12-22 23:35:37
 * @LastEditTime: 2021-12-23 12:24:17
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \json-serveg:\桌面2\50htmljs\jokes\script.js
 */
const jokeEl = document.getElementById('joke')
const btn = document.getElementById('jokeBtn')

btn.addEventListener('click',generateJoke)

generateJoke()

async function generateJoke(){
    let response = await fetch('https://icanhazdadjoke.com',{
        headers: {
            Accept: 'application/json',
          }
    })
    let  data = await response.json()
    jokeEl.innerHTML = data.joke
}